System for interconnecting software components in an object oriented programming environment using a separate editor object for each run-time object instantiated for each selected component

ABSTRACT

A method and system for interconnecting software components. In a preferred embodiment, the present invention instantiates an event object. The event object includes message information describing the message and a dispatching member function for invoking a member function of a target object passing the message information. A message is passed by invoking the dispatching member function of the event object passing an identifier to a target object and an identifier of a member function of the target object. The dispatching member function invokes the identified member function of the identified target object passing the event information as an actual parameter. The event object is preferably of a derived class that inherits a base class. The base class provides common event behavior, while the derived class provides behavior specific to a type of message.

CROSS-REFERENCE TO RELATED APPLICATION

This application is a division of U.S. patent application Ser. No.08/153,362, filed Nov. 16, 1993.

TECHNICAL FIELD

The present invention relates generally to a computer system for visualprogramming, and more specifically, to a method and system forinterconnecting visual components and passing messages between connectedcomponents.

BACKGROUND OF THE INVENTION

Visual programming is a computer programming technique that allows forrapid development of visually oriented programs (visual programs). FIG.1 is a diagram illustrating a sample operation of a visual program. Thevisual program is a temperature converter, which converts Fahrenheit toCentigrade, and vice versa. The Fahrenheit scroll bar 101 is used to setthe Fahrenheit value to between 0 and 100 degrees as indicated by theposition of the Fahrenheit slider 103. The Fahrenheit display 102displays the numeric Fahrenheit value represented by the position of theFahrenheit slider. The Centigrade scroll bar 111 is used to set theCentigrade value between 0 and 100 degrees as indicated by theCentigrade slider 113. The Centigrade display 112 displays the numericCentigrade value represented by the position of the Centigrade slider.In operation, when the Fahrenheit slider is moved by a user, theCentigrade slider is automatically moved to the corresponding Centigradeposition and the Fahrenheit and Centigrade displays are updated.Conversely, when the Centigrade slider is moved by a user, theFahrenheit slider is automatically moved to the corresponding Fahrenheitposition and the Centigrade and Fahrenheit displays are updated.

Visual programming allows various components (e.g., a scroll bar) to beinterconnected visually to effect the program behavior. A visualprogramming environment typically includes a list of predefinedcomponents that can be interconnected to create a visual program. Eachcomponent may include input and output ports and a visual interface.When creating a visual program, a programmer specifies the visualcomponents and their location on the display. The programmer alsospecifies the interconnection between various ports. The components passvalues through these connections. FIG. 2 is a block diagram illustratinga scroll bar component. The scroll bar component 201 receives messagesfrom the operating system (e.g., mouse down) and controls the display ofa scroll bar. The scroll bar also provides an input port 203 and anoutput port 202. The input port is used to receive a value indicating anew position of the slider and the output port is used to send a valueindicating a new slider position. The scroll bar can be connected toother components through its ports.

FIG. 3 is a diagram illustrating a scroll bar connected to a displaycomponent. A display component 301 has one input port 303 for receivinga value. The display component controls the displaying of the value thatit receives. The output port 202 of the scroll bar component 201 isconnected to the input port 303 of the display component. In operation,whenever the scroll bar slider is moved, a value indicating the newposition of the slider is sent from the scroll bar component to thedisplay component. The display component receives this value and updatesits display accordingly.

Although prior references have described general visual programmingenvironments, visual programming is not widespread because of theinefficiencies of visual programs. For example, visual programs oftenexecute in an interpretive mode that results in unacceptably slowperformance.

SUMMARY OF THE INVENTION

It is an object of the present invention to provide a method and systemthat allows for creation of efficient visual programs.

It is another object of the present invention to provide a method andsystem that shields component developer from the details of theconnecting of components and the passing of values between components.

These and other objects, which will become apparent as the invention ismore fully described below, are obtained by an improved method andsystem for sending messages between components. In a preferredembodiment, the present invention instantiates an event object. Theevent object includes message information describing the message and adispatching member function for invoking a member function of a targetobject passing the message information. A message is passed by invokingthe dispatching member function of the event object passing anidentifier to a target object and an identifier of a member function ofthe target object. The dispatching member function invokes theidentified member function of the identified target object passing theevent information as an actual parameter. The event object is preferablyof a derived class that inherits a base class. The base class providescommon event behavior, while the derived class provides behaviorspecific to a type of message.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a diagram illustrating a sample operation of a visual program.

FIG. 2 is a block diagram illustrating a scroll bar component.

FIG. 3 is a diagram illustrating a scroll bar connected to a displaycomponent.

FIG. 4 is a diagram illustrating visual programming of the presentinvention.

FIG. 5 is a diagram illustrating the instantiated objects for thetemperature converter.

FIG. 6 is a table containing a listing of the connections for the forthe temperature converter program.

FIG. 7 is a flow diagram illustrating the flow of control of sending amessage from a source object to a target object.

FIG. 8 is a block diagram of data structures of a CEditor object.

FIG. 9 is a block diagram of a computer system.

DETAILED DESCRIPTION OF THE INVENTION

The present invention provides a method and system for connectingcomponents and passing of messages (events) between components. In apreferred embodiment, each component may provide multiple input portsand output ports. Each output port sends a message corresponding to aparticular type of event; each input port receives a messagecorresponding to a particular type of event. A component that sends amessage is referred to as a source, and a component that receives themessage is referred to as the target. In a preferred embodiment, eachcomponent has an associated run-time class and editor class. The editorclass provides component-specific behavior to assist in creating avisual program. The run-time class provides the component behavior whenthe visual program executes. A visual programming system controls thedevelopment of visual programs by instantiating objects of the editorclasses and controls the run-time execution by instantiating objects ofthe run-time class. As described below, the present invention provides amechanism in which messages are efficiently passed between components.In the following, a preferred embodiment of the present invention isdescribed using well-known object-oriented terminology and terminologyof the C++ programming language.

FIG. 4 is a diagram illustrating visual programming of the presentinvention. To generate a visual program to implement a temperatureconverter, a programmer would position a Fahrenheit scroll bar 401, aFahrenheit display 430, a Centigrade scroll bar 420, and a Centigradedisplay 440. The programmer would also position an FtoC calculator 460,which converts a Fahrenheit value to a Centigrade value, and a CtoFcalculator 450, which converts a Centigrade value to a Fahrenheit value.In one embodiment, the components are selected from an extendible listof available components. The programmer then connects the componentsthrough their ports. The connections 412→461 and 412→431 indicate thatwhen the Fahrenheit scroll bar is changed (e.g., slider moved), the newvalue is sent to the FtoC calculator and the Fahrenheit display. Theconnection 462→421 indicates that when the FtoC calculator calculates anew Centigrade value, the new value is sent to the Centigrade scrollbar. The connections 422→441 and 422→451 indicate that when theCentigrade scroll bar is changed, the new value is sent to the CtoFcalculator and the Centigrade display. The connection 452→411 indicatesthat when the CtoF calculator calculates a new Fahrenheit value, the newvalue is sent to the Fahrenheit scroll bar. In one embodiment, thecomponents are connected by entering a connect mode and selecting thesource and target of each connection.

The visual programming system instantiates an object of the run-timeclass for each component selected by the programmer. FIG. 5 is a diagramillustrating the instantiated objects for the temperature converter. TheFScrollbar object 501 corresponds to the Fahrenheit scroll barcomponent, the CScrollbar object 502 corresponds to the Centigradescroll bar component, the FDisplay object 503 corresponds to theFahrenheit display component, the CDisplay object 504 corresponds to theCentigrade display component, the FtoC object 505 corresponds to theFtoC calculator component, and the CtoF object 506 corresponds to theCtoF calculator component. Each of these objects implements the displayand control of the corresponding component. The directed arcs indicatethe direction of the connections, that is, from an output port to aninput port.

Each component may send messages to other components corresponding todifferent types of events. For example, a scroll bar may send a messageto indicate a changed value event has occurred and another message toindicate a scroll down hat occurred. Each type of event has its ownoutput port. Also, input ports are designated to receive only certaintypes of events. For example, an output port that sends messagesrelating to a scroll up event can only be connected to an input portthat expects a message in the same format as a scroll up message.

A source object (corresponding to a source component) sends a message(communicates the occurrence of an event) by invoking a member functionof a target object (corresponding to a target component). Each input andoutput port is preferably associated with a function member of therun-time object. For example, a scroll bar object may have a functionmember named ValueIn corresponding to an input port for receiving a newvalue and a function member named ValueOut corresponding to an outputport for sending a new value. In operation, the member function ValueOutis invoked whenever a change in the value for the scroll bar occurs,e.g., when the slider is moved. The member function ValueOut invokes thetarget member function corresponding to each input port to which it isconnected. The invoked target member function then processes the valueinformation which is passed as a parameter.

In a preferred embodiment, message information (e.g., new value) isencapsulated in an object of an event class. The source member functioncorresponding to an output port creates an event object and stores theevent information in the event object. The source member functioneffects the invocation of a notify member function of a target objectpassing the event object and a pointer to the target member function.The notify member function invokes a dispatching member function of theevent object passing a pointer to the target object and a pointer to thetarget member function. The dispatching member function invokes thetarget member function passing the stored information as a parameter. Ina preferred embodiment, different implementations of event objects areused to represent different function prototypes (parameter list) oftarget member functions. Each class of event object contains informationthat is passed to a target member function according to the functionprototype. Thus, each source member function invokes target memberfunctions with the same prototype.

In a preferred embodiment, each run-time class inherits the classCObject. The class CObject tracks the connections and controls thesending of messages. The class CObject is referred to as a connectionmanager. In this way, run-time classes that implement component behaviorcan be developed without detailed knowledge of the implementation of theclass CObject. Moreover, run-time objects implemented by differentdevelopers can cooperatively interact. FIG. 6 is a table containing alisting of the connections for the for the temperature converterprogram. The class CObject includes an array (connectionArray) thatcontains the connections for each output port of the run-time object.Each entry of the connection array contains an identifier of the outputport of the source object, an identifier of the target object, and anidentifier of the input port of the target object. For example, theconnection array for the FScrollbar object contains two entries:

    (Out1, FDisplay, In1) and (Out1, FtoC, In1)

"Out1" identifies the output port, "FDisplay" and "FtoC" identify thetarget objects, and "In1" identifies the input port of the targetobjects. When an event occurs for a particular output port, the sourceobject instantiates an event object and invokes an inform targets memberfunction of the class CObject (connection manager) identifying theoutput port. The output port is preferably identified by a pointer to amember function (source member function) of the source object. Theinform targets member function sends an appropriate message to eachtarget object as indicated by the connection array for the sourceobject. The input port is preferably identified by a pointer to a memberfunction (target member function) of the target object. The connectionmanager sends the message to the target object by invoking a notifymember function of the target object passing a pointer to the targetmember function and an event object. The event object contains actualparameters for the target member function. The notify member functioninvokes a dispatch member function of the event object passing a pointerto the target member function and a pointer to the target object. Thedispatch member function formats the actual parameters and invokes thetarget member function of the target object passing the actualparameters.

Code Table 1 contains pseudocode for the class CObject.

                                      Code TABLE 1    __________________________________________________________________________    class CONNECTION    {CObject *ptarget;     ULONG pmftarget;     ULONG pmfsource;    class CObject    {     boolean isRecursing;     CONNECTION connectionArray[10];     int connectionCount;     virtual boolean NotifyEvent (CEvent *pevent, CObject *psource, ULONG    pmftarget);      boolean InformTargets(CEvent *pevent, ULONG pmfsource);      void AddTarget(CObject *ptarget, ULONG pmftarget, ULONG pmfsource);     virtual void Serialize(CArchive &ar);     virtual VOID WriteConnectionArray(CArchive &ar);     virtual VOID ReadConnectionArray(CArchive &ar);     virtual VOID SerializeObjectData(CArchive &ar),    };    BOOL CObject::NotifyEvent (CEvent *pevent, CObject *psource, ULONG    pmftarget)    {     BOOL ret,     if (isRecursing) return FALSE;     isRecursing = TRUE:     if (pevent -22  IsKindOf(CValueEvent))      ret = ((CValueEvent*)pcvent)->Dispatch(psource, this, pmftarget);     else if      .      .      .     else return FALSE;     isRecursing = FALSE;     return ret;    }    BOOL CObject::InformTargets(CEvent *pevent, ULONG pmfsource)    {     for(i = 0; i < connectionCount; i++)     {      if (connectionArray[i].pmfsource == pmfsource)       connectionArray[i].pmfiarget->NotifyEvent(pevent, this,    connectionArray[i].pmftarget);     }    }    void CObject::AddTarget(CObject *ptarget, ULONG pmftarget,ULONG    pmfsource)    {     i = connectionCount++;     connectionArray[i].ptarget = ptarget;     connectionArray[i].pmftarget = pmftarget;     connectionArray[i].pmfsource = pmfsource;    }    __________________________________________________________________________

The programming system adds connections to a run-time object by invokingthe member function AddTarget provided by the connection manager. Theprogramming system invokes the AddTarget member function of the sourceobject whenever a programmer connects two objects. The member functionAddTarget is passed a pointer to the target object, a pointer to thetarget member function (representing the input port), and a pointer to asource member function (representing the output port). The memberfunction AddTarget adds an entry to the connectionArray of the sourceobject corresponding to the passed parameters. In a preferredembodiment, the connections are stored not as data members of theCObject, but rather are stored in a heap that is shared by all run-timeobjects. In this way, the storage overhead for each object can beminimized.

A message is sent to a target object in the following manner. The sourceobject instantiates an event object and stores event information in theevent object. The source object invokes the member functionInformTargets of its connection manager passing the event object and apointer to the source member function. For each connection for thatoutput port (source member function), the connection manager invokes themember function NotifyEvent of target object passing the event object, apointer to the target member function, and a pointer to the sourceobject. The member function NotifyEvent invokes the member functionDispatch of the event object passing a pointer to the source object, apointer to the target object, and a pointer to the target memberfunction. The member function Dispatch invokes the target memberfunction of the target object passing the stored event information asactual parameters. An event object encapsulates the message informationin a way that is transparent to the connection manager. Thus, theconnection manager can control the invoking of target member functionspassing arbitrary parameters.

FIG. 7 is a flow diagram illustrating the flow of control of sending amessage from a source object to a target object. A source memberfunction 710-714 of the source object instantiates an event object instep 711. In step 712, the source member function stores the eventinformation in the event object. In step 713, the source member functioninvokes the member function InformTargets of the connection managerpassing a pointer to the event and the source member function. In step721, the member function InformTargets loops determining which entriesin the connection array correspond to the source member function. Whenan entry is found, the member function InformTargets invokes the memberfunction NotifyEvent of the target object passing a pointer to theevent, a pointer to the source object, and a pointer to the targetmember function. In step 731, the member function NotifyEvent of thetarget object invokes the member function Dispatch of the event passinga pointer to the source object, a pointer to the target object, andpointer to the target member function. In step 741, the member functionDispatch invokes the target member function passing the eventinformation stored in the event object. The target member functionprocesses the event information in step 751. The target member functionthen returns, which causes the member functions Dispatch, NotifyEvent,and InformTargets to return to the execution of the source memberfunction.

The use of an event object allows the connection manager to invoke inputmember functions with arbitrary parameters. Each prototype for a inputmember function has its own implementation of the event class to handlethe event. The source object instantiates the appropriate class of eventobject. For example, the input member function ValueIn is passed aninteger. Thus, an event class is implemented that contains an integerdata member to store the value. The member function Dispatch of theevent class invokes a passed target member function passing the storedvalue. An event class may be implemented for each different prototype ofa target member function. For example, if the event information includesboth an integer and a string, then an event class can have a data memberfor the integer and another for the string. The member function Dispatchof the event class invokes a passed target member function passing theinteger and the string as parameters.

Code Table 2 contains pseudocode that describes the event classes. Eachevent class derives from the class CEvent. The event class CIntEvent isused to pass information stored as an integer to a target memberfunction. The member function Dispatch is passed a pointer the targetobject and a pointer to the member function. The member functionDispatch invokes the target member function by the following statement:

    (ptarget→*(LongToMember(pmftarget)))(numValue)

The event class CActionEvent is used to pass messages with nocorresponding data, and the event class CStringEvent is used to passmessages with string data.

    __________________________________________________________________________    class CEvent    public:     CEvent();     virtual BOOL Dispatch (CObject *psource, CObject *ptarget, ULONG    pmftarget)= 0;    }    class CActionEvent: public CEvent    {    public:     virtual BOOL Dispatch (CObject *psource, CObject *ptarget, ULONG    pmftarget)     {(ptarget->*(LongToMember(pmf)))()};    }    class CINtEvent: public CEvent    {    public:     INT numValue;     virtual BOOL Dispatch (CObject*psource, CObject *ptarget, ULONG    pmftarget)     {(ptarget- >*(LongToMember(pmftarget)))(numValue)};    }    class CStringEvent: public CEvent    {    public:     STRING stringValue;     virtual BOOL Dispatch (CObject *psource, CObject *ptarget, ULONG    pmftarget);     {(ptarget->*(LongToMember(pmftarget)))(stringValue)};    }    __________________________________________________________________________

Code Table 3 contains pseudocode for a sample scroll bar objectcorresponding to a scroll bar component. The scroll bar object isdefined by class CScrollbar, which inherits the connection manager(class CObject). The class contains data members to store the currentvalue of the scroll bar, a large and small increment for the scroll bar,and the minimum and maximum values for the scroll bar. The class alsocontains the member function to set and retrieve the current value, toreceive messages from the parent window of that scroll bar, and toeffect various scroll bar behaviors. The scroll bar component has aninput function member (value) with one parameter and an output functionmember (value) with no parameters.

The constructor CScrollbar registers the scroll bar with the operatingsystem and initializes its data members. The member functionHandleParentMsg receives messages from the parent window and dispatchesthe message. For example, if the member function HandleParentMsg ispassed a message that the scroll bar event line up (SB₋₋ LINEUP) hasoccurred, then the member function invokes the member function LineUp.The member function LineUp instantiates a CActionEvent object, sets apointer to the member function LineUp, and invokes the member functionInformTargets of the connection manager. The member function LineUp theninvokes the member function value passing a new value for the scrollbar.

The member function value receives the new value. If the new value isdifferent than the current value, then the member function adjusts theslider, instantiates a CIntEvent object, sets the event object to thenew value, sets a pointer to the member function value (to identify thesource member function), and invokes the member function InformTargetsof the connection manager.

The member function minimum illustrates a member function of an objectthat does not cause a message to be sent to target objects, that is, itdoes not correspond to an output port. The member function minimum,however, may correspond to an input port. In one embodiment, a memberfunction could correspond to both an input and an output port (abidirectional port). The member function can be invoked to receive amessage and then send a message to other target objects.

In a preferred embodiment, the present invention is implemented toexecute under the Windows operating system developed by MicrosoftCorporation. The Windows operating system is described in "ProgrammingWindows" written by Charles Petzold and published by MicrosoftCorporation, which is hereby incorporated by reference.

                  Code TABLE 3    ______________________________________    class CScrollbar: CObject, CWindow     INT      m.sub.-- largeChange;     INT      m.sub.-- smallChange;     INT      m.sub.-- value;     INT      m.sub.-- minimum;     INT      m.sub.-- maximum;     BOOL     m.sub.-- isVert;              CScrollBar();              CScrollBar(const VRect &pos, CWindow *parent, boolean isVert);     virtual INT              largeChange();     virtual VOID              largeChange(INT);     virtual INT              smallChange();     virtual VOID              smallChange(INT);     virtual INT              value();     virtual VOID              value(INT);     virtual INT              minimum();     virtual VOID              minimum(INT);     virtual INT              maximum();     virtual VOID              maximum(INT);     virtual VOID              lineUP();     virtual VOID              lineDown();     virtual VOID              pageUP();     virtual VOID              pageDown();     virtual LONG HandleParentMsg(HWND hwnd, unsigned wm, WORD wParam, LONG    IParam);    }    CScrollBar::CScrollBar(const VRECT &pos, CWindow *parent, BOOL isVert)     DWORD style;     if (isVert)      style = WS.sub.-- CHILD | SBS.sub.-- VERT;     else      style = WS.sub.-- CHILD | SBS.sub.-- HORZ;     m.sub.-- isVert = isVert;     CWinWindow::Init(                parent,                NULL,                0L,                "SCROLLBAR",                "",                style,                pos.left,                pos.top,                pos.right - pos.left,                pos.bottom - pos.top,                NULL,                NULL);     smallChange(1);     largeChange(10);     minimum(0);     maximum(100);     value(0);    }    VOID CScrollBar::lineUp()    {     CActionEvent evt;     VOID (ScrollBar::*mfp)() = &CScrollBar:lineUp;     InformTarget(&evt, MemberToLong(mfp));     value(m.sub.-- value-m.sub.-- smallChange);    }    VOID CScrollBar::value(INT theValue)    {     if(theValue < m.sub.-- minimum      theValue = m.sub.-- minimum     if(theValue > m.sub.-- maximum      theValue = m.sub.-- maximum     if (m.sub.-- value != theValue)     {      m.sub.-- value = theValue;      if (m.sub.-- hwnd != NULL)       SetScrollPos(GetHwnd(), SB.sub.-- CTL, m.sub.-- value, TRUE);      CIntValue numEvent;      INT (CScrollBar::*mfp)() = &CScrollBar::value;      numEvent.numValue = m.sub.-- value;      InformTargets(&numEvent, (ULONG)MemberToLong(mfp));     }    }    VOID CScrollBar::minimum(INT theMinimum)    {     m.sub.-- minimum = theMinimum     if (m.sub.-- hwnd != NULL)      SetScrollRange(GetHwnd(), SB.sub.-- CTL, m.sub.-- minimum, m.sub.--    maximum, TRUE);     if (m.sub.-- < the Minimum)      value(theMinimum);    }    LONG ScrollBar::HandleParentMsg(                      HWND hwnd,                       unsigned wm,                       WORD wParam,                       LONG lParam)    {     switch(wm)     {      case WM.sub.-- HSCROLL:      case WM.sub.-- VSCROLL:      switch(wParam)      {       case SB.sub.-- LINEUP:                      lineUp(); break;       case SB.sub.-- LINEDOWN:                       lineDown(); break;       case SB.sub.-- PAGEUP:                       pageUp(); break;       case SB.sub.-- PAGEDOWN:                       pageDown(); break;       case SB.sub.-- TOP:                       value(minimum()); break;       case SB.sub.-- BOTTOM                       value(maximum()); break;       case SB.sub.-- TRACK:       case SB.sub.-- THUMBPOSITION                       value(LOWORD)(lParam)); break;       case SB.sub.-- ENDSCROLL:                       break;      }      default: break;     }     return CWinWindow::HandleParentMSG(hwnd, wm, wParam, lParam);    }    ______________________________________

In a preferred embodiment, the programming system persistently storesthe run-time objects of a visual program. The programming systemmaintains a pointer to each run-time object corresponding to acomponent. To store the program, the programming environment invokes amember function Serialize (provided by the connection manager of eachobject). The member function Serialize writes the connection array tothe persistent storage and invokes the member functionSerializeObjectData to write the object specific data to the persistentstorage. The member function SerializeObjectData of the connectionmanager would typically be overridden by the run-time objectcorresponding to the component. For example, the member functionSerializeObjectData for the scroll bar object writes each data member topersistent storage. Similarly, each object has corresponding memberfunctions to retrieve the persistent stored data. When storing andretrieving data, the programming system needs to map the memory addressof each pointer to its persistently stored object data. When the objectdata is retrieved, the pointers in the connection array need to bemapped to their new memory locations.

In a preferred embodiment, each component has a corresponding editorobject which controls the placement, movement, and connection to thecomponent. A standard interface (CEditor) to the editor object isprovided. The CEditor object provides a standard mechanism (1) fordisplaying the available ports and the current connections, (2) forselecting an available port, (3) for connecting a port to another port,and (4) for moving the component. The implementor of a componentpreferably implements an editor object that inherits the CEditorinterface. When a programmer selects a component, the programming systeminstantiates both the run-time object and an editor object for thecomponent.

FIG. 8 is a block diagram of data structures of a CEditor object. TheCEditor object 802 contains a pointer to a list of available ports(mPortList), a pointer to a user interface editor object (mEditorUI), apointer to the run-time object corresponding to the component(mSubject), a pointer to a list of child editor object (mChildEditors),and a pointer to a parent editor (mParent). Each port is described by aCEditPort object 808. A CEditPort object contains a pointer to theassociated CEditor object (mOwnerEditor), a pointer to a list of inputports to which the port is connected (mConnectedPorts), statusinformation (mStatus), and pointer to member functions identifying theinput and output portions of the port (mValueIn and mValueOut) aspointers to member functions. The CEditorUI object 812 contains memberfunctions to control moving the component on the display and displayingavailable ports and connections.

A component may contains child components. For example, a windowcomponent (parent component) may contain a scroll bar component. TheCEditor object for the window contains pointers to each child CEditorobject.

The visual programming environment tracks the first level of parentcomponents. Each CEditor object tracks its child CEditor objects. Whenan event occurs (e.g. mouse button down), the programming environmentpasses the event to the appropriate first level component. The firstlevel component is responsible to passing the event on the appropriatechild component.

Code Table 4 is pseudocode for the class CEditor. The CEditer classinherits the CObject class. This inheritance allows connections betweenCEditor objects to be controlled by the connection manager. The CEditorobjects are, thus, connected in a manner similar to the way the run-timeobjects are connected. The CEditor object includes a constructor andmember function to delete an object.

                  Code TABLE 4    ______________________________________    class CEditor: public CObject    public:      CEditor(CEditor* pEditor, CObject* pSubject);     virtual VOID ObjectDeleted(CObject* object);     virtual VOID PortChanged(CEditPort* port);     VString mName;    private:     CEditPortListPtr mPortList;     CEditorUIPtr mEditorUI;     CObjectPtr mSubject;     CEditorLisPtr mChildEditors;     CEditorPtr mParent;    };    VOID CEditor::ObjectDeleted(CObject* object)    {     for each CEditPort port1 in mPortList      if (port1 is connected)       for each CEditPort port2 in mConnectedPorts of port1        if (port2.mSubject == object)         port1->Disconnect(port2)     RemoveTarget(object);     mSubject->RemoveTarget(object);     for each CEditorUI eui in mEditorUIList      eui->RemoveTarget(object);    };    ______________________________________

Code Table 5 contains pseudocode defining CEditorUI class. The CEditorUIclass provides a standard mechanism for editing connections betweencomponents and movement of components. When a programmer selects to adda component to a visual program, the programming system instantiates theobject, an CEditorUI for the object, and a CEditor object for theobject. In a preferred embodiment, the programmer can move a componentby clicking on the component. A tracker box is drawn and the user canthen drag the component to a new position.

                  Code TABLE 5    ______________________________________    class CEditorUI: public CObject, CWindow    public:     virtual void                Draw(const VRect& rectUpdate);     virtual BOOL                OnMouseStart(CUserEvp *, VPoint, INT, INT);     virtual BOOL                OnMouseDrag(CUserEvp *, Vpoint, BOOL);     virtual BOOL                OnMouseEnd(CUserEvp *, VPoint, BOOL);     virtual void                PositionChange();     BOOL showTracker;     VPoint startSize;     VPoint startPoint;     WORD dragMode,     virtual BOOL                MakeStdUI(CEditor*, CWindow*);     virtual BOOL                NotifyEvent(CEvent* ev,                 CObject* sender,                 ULONG action);     CPopMenuPtr                m.sub.-- popup;     CPropertyDialogPtr                m.sub.-- dialog;    private:     CEditorPtr mEditor;     BOOL       mIsActive;    };    ______________________________________

The programming system invokes the member function Draw to request thecomponent to draw a tracker box. The programming system invokes themember function OnMouseStart to indicate that object is being selected,the member function OnMouseDrag to indicate the new position of thetracker, and the member function OnMouseEnd to indicate that thetracking is complete. The member function OnMouseEnd invokes the memberfunction PositionChange to pass the new position to the CEditorUI objectthat is specific to the component (e.g., scroll bar).

The member function MakeStdUI initializes a standard user interface forthe component. The standard user interface includes a menu for selectingto delete the component, to move or size the component, or to changeproperties of the component. The CEditorUI provides a standard dialogfor displaying available ports and current connections. For example, alist of available ports would be

    ______________________________________    Name     Type        Input Member                                    Output Member    ______________________________________    Position CIntEvent   6          7    PageUp   CActionEvent                         11         12    ______________________________________

Code Table 6 contains pseudocode describing the CEditPort class. Thisclass provides member functions to manage the actual connection betweencomponents. When two ports are selected for connection, the programmingsystem invokes the member function Connect of the output port passingthe input port. The member function Connect adds the target object tothe connection array of the source object and adds the input port to thelist of connections for the editor object.

                  Code TABLE 6    ______________________________________    class CEditPort: public CObject    public:     virtual BOOL Connect(CEditPort* OtherPort);     virtual BOOL Disconnect(CEditPort* OtherPort);    private:     VString      mName,     CEditorPtr   mOwnerEditor,     CObjectPtr   mSubject;     CEditPortListPtr mConnectedPorts;     BOOL         mIsConnected: 1;     BOOL         mIsOutput: 1;     BOOL         mIsInput: 1;     BOOL         mCanRead: 1;     BOOL         mCanWrite: 1;     CObjectPtr   mValueIn     CObjectPtr   mValueOut;    };    BOOL CEditPort::Connect(CEditPort* OtherPort)    {     mSubject->AddTarget(                  OtherPort->mSubject,                  OtherPort->MValueOut);     mIsConnected = TRUE;     mConnectedPorts->Add(OtherPort);     return TRUE;    }    ______________________________________

Code Table 7 contains pseudocode for an implementation of the CEditorclass for a scroll bar component. The implementation provides aconstructor for the CEScrollBar class that inherits the CEditor class.The Constructor instantiates a CEditPort object for each port for thescroll bar component. In this example, the ports are "value" and"LineUp." The port value is a bidirectional port, that is, the memberfunction value can be connected to an input and output port. Theconstructor also creates a CEScrollBarUI object. Code Table 8 containspseudocode for the EScrollBarUI class.

                  Code TABLE 7    ______________________________________    class CEScrollBar: CEditor    {CEScrollBar(CEditor* pParentEditor,       CWindow* pParentWindow       CObject* pSubject);    };    CEScrollBar::CEScrollBar(CEditor* pParentEditor,       CWindow* pParentWindow,       CObject, pSubject)        :CEditor(pParentEditor, pSubject)     CEditPort* pp;     void (CScrollBar::*mfp3)();     {      INT (CScrollBar::*mfp1)() = &CScrollBar::value;      void (CScrollBar::*mfp2)(INT) = &CScrollBar::value;      pp = new CNumEditPort(this, "Value");      pp->isOutput(TRUE);      pp->valueOut((CObject*)MemberToLong(mfp1));      pp->isInput(TRUE);      pp->valueIn((CObject*)MemberToLong(mfp2));      pp->canRead(TRUE);      pp->canWrite(TRUE);      portList()->Add(pp);     }     pp = new CEditPort(this, "Line Up");     pp->isInput(TRUE);     pp->valueIn((CObject*)MemberToLong(mfp3 = &CScrollBar::lineUp));     portList()->Add(pp);     CEScrollBarUI* ui = new CEScrollBarUI(this, pParentWindow);     editorUIList(new CEditorUIList);     editorUIList()->Add(ui);    }    ______________________________________

                  Code TABLE 8    ______________________________________    class CEScrollBarUI:CEditorUI    {CEScrollBarUI(CEditor*,CWindow*)}    CEScrollBarUI:CEScrollBarUI(                       CEditor* pEditor,                       CWindow* pParentWindow)     editor(pEditor);     parent(pParentWindow);     CObject*po = editor()->subject();     position( ((CWindow*)po)- >position() );     MakeStdUI(pEditor, pParentWindow);    }    ______________________________________

FIG. 9 is a block diagram illustrating a computer system forimplementing the present invention. The computer system 901 includescentral processing unit 902, memory 903, storage 904, display 905, andinput device 906. In a preferred embodiment, objects are instantiated inmemory and persistently stored to storage. Visual programs output datato the display and input data from the input device.

Although the present has been described in terms of a preferredembodiment, it is not intended that the invention be limited to thisembodiment. Modifications within the spirit of the invention will beapparent to those skilled in the art. The scope of the present inventionis defined by the claims which follow.

I claim:
 1. A method in a computer system for composing a visualprogram, the method comprising the steps of:when selecting each of aplurality of components to be included in the visual program,instantiating a run-time object to implement the behavior of eachselected component and instantiating an editor object for each selectedcomponent; and under control of the instantiated editor object for acomponent,displaying a list of available ports for the instantiatedrun-time object that implements the behavior of the component, eachavailable port corresponding to an event associated with the component;selecting a displayed port; and directing the instantiated run-timeobject that implements the behavior of the component to establish aconnection between the selected port and a target object, whereby duringexecution of the visual program the instantiated run-time object thatimplements the behavior of the component sends an indication of theevent to each target object connected to the port upon occurrence of theevent.
 2. The method of claim 1 wherein the editor objects controldisplaying a visual representation of the components during compositionof the visual program.
 3. The method of claim 1 wherein the run-timeobjects control displaying a visual representation of each of thecomponents during composition of the visual program and the editorobjects control positioning of the visual representation.
 4. The methodof claim 1 wherein each run-time object inherits a manager class havingmember functions for establishing the connection, wherein the editorobjects invoke the member function to store in the run-time objects anindication of the connection.
 5. The method of claim 1 wherein each portis a member function of the source object.
 6. The method of claim 1wherein the editor objects inherit a managing editor class forcontrolling the establishment of the connection.
 7. The method of claim1 wherein each editor objects contain a reference to an editor userinterface object for controlling interactions with a programmer of thevisual program.
 8. The method of claim 1 wherein each component containsa plurality of sub-components and the editor objects contain a referenceto each editor object corresponding to a sub-component.
 9. Acomputer-readable medium containing instructions for composing a visualprogram by:when selecting each of a plurality of components to beincluded in the visual program, instantiating a run-time object toimplement the behavior of each selected component and instantiating aneditor object for each selected component; under control of theinstantiated editor object for a component,displaying a list ofavailable ports for the instantiated run-time object that implements thebehavior of the component, each available port corresponding to an eventassociated with the component; selecting a displayed port; and directingthe instantiated run-time object that implements the behavior of thecomponent to establish a connection between the selected port and atarget object, whereby during execution of the visual program theinstantiated run-time object that implements the behavior of thecomponent sends an indication of the event to each target objectconnected to the port upon occurrence of the event.
 10. Thecomputer-readable medium of claim 9 wherein the editor objects controldisplaying a visual representation of the components during compositionof the visual program.
 11. The computer-readable medium of claim 9wherein the run-time objects control displaying a visual representationof each of the components during composition of the visual program andthe editor objects control positioning of the visual representation.